package com.yanwq.nwa.user;

import android.text.TextUtils;
import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.yanwq.nwa.entity.User;
import com.yanwq.nwa.util.CacheUtil;

/**
 * Author dodoca_android.
 * Date 2017/4/26.
 */

public class UserMgr {

    public static void save(User user) {
        String s = JSON.toJSONString(user);
        Log.d("temp", s);
        CacheUtil.putCache("user", s);
    }

    public static User get() {
        String s = CacheUtil.getCache("user", "");
        Log.d("temp", s == null ? "null" : s);

        if (TextUtils.isEmpty(s)) {
            return null;
        }
        return JSON.parseObject(s, User.class);
    }

    public static String getUuid() {
        User user = get();
        return user == null ? "" : user.getUuid();
    }
}
